<template>
	<view class="page content-20 page-bg">
		<view v-if="items.length <= 0" class="empty">
			<u-empty mode='list' text='您还没有添加爱宠噢~'></u-empty>
		</view>
		<view v-else class="item" v-for="item in items" :key='item.id'>
			<view class="item-box">
				<image  class="avatar item-img" :src="item.avatar" mode=""></image>
				<view class="item-info">
					<view class="title item-title">{{item.nickName}}({{item.varietiesView}})</view>
					<view class="item-desc">{{item.petColor}} | {{item.weight}}kg | {{common.petsSex[item.petSex]}}</view>
				</view>
				<view class="item-btn btn-theme" @click="editPets(item)">编辑</view>
			</view>
			<!-- <view class="limit">
				<view class="limit-com link" @click="$link('/pagesMine/petsHistory')">
					<view class="con">距下次免疫<text class="title theme">56</text>天</view>
					<u-icon name='arrow-right' size='20'></u-icon>
				</view>
				<view class="limit-com link">
					<view class="con">距下次驱虫<text class="title theme">56</text>天</view>
					<u-icon name='arrow-right' size='20'></u-icon>
				</view>
			</view> -->
		</view>
		<view class="footer-block"></view>
		<view class="footer-block"></view>
		<view class="circular-submit circular-submit-pop" @click="$link('/pagesMine/petsAdd')">+ 添加爱宠</view>
	</view>
</template>

<script>
	import common from '../utils/common.js'
	import api from '../utils/api.js'
	export default {
		data() {
			return {
				pageIndex: 1,
				pageSize: 10,
				totalCount: 0,
				items: [],
				common
			}
		},
		
		onLoad() {
			this.pageSize = common.pageSize
			this.getItems()
		},
		
		methods: {
			getItems() {
				api.getPetList({ },(res) => {
					 this.items = res
				}) 
			},
			
			editPets(item) {
				common.setStorage('editPets', item)
				this.$link('/pagesMine/petsAdd?op=edit')
			}
		}
	}
</script>

<style scoped lang="scss">
	.item{
		margin-bottom: 20upx;
	}
	.empty{
		margin-top: 100px;
	}
	.item-desc{
		font-size: $font-size-26;
		color: #666666;
		line-height: 26upx;
		margin-top: 10upx;
	}
	.limit{
		margin-top: 30upx;
		padding-top: 30upx;
		border-top: 1px solid $border-color;
		@include flex-base;
		justify-content: space-between;
	}
	.limit-com{
		font-size: $font-size-26;
		color: #666666;
	}
	.theme{
		color: $theme-color;
	}
	.con{
		padding-right: 10upx;
	}
</style>
